Skip to content

Conversation

@snowystinger
Copy link
Member

@snowystinger snowystinger commented May 27, 2025

Closes

Follow instructions in README to run the plugin. There is also a description of the extension architecture in there as it is non-trivial due to the various sandbox that chrome imposes in addition to the different ways that a macro could be updated ie. static, dynamic, conditional static.

Note, there is a parcel bug which will cause all tabs that have had the content script injected to reload on every change. I cannot resolve this right now. If you build instead so that the extension doesn't change, then it won't do this. It's only during HMR. This will also cause every tab to refresh if a tab that had loaded the extension is closed.
For this reason, it can be easier to build the extension instead of running it as if you're developing.

Some notes, this is currently meant to be used in addition to the regular panels and AtomicCSS to determine where styles are coming from. It is not designed to replace those extensions and inspectors.

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

I added a style macro in the commit e5ab27b which is static and is swapped with another static one on a span inside buttons. It reacts to the button being focused. You can see the extensions dev panel is updated when this swap occurs despite it being a static macro.

I removed that afterwards. So to test the updates on static macros, use that storybook build.

Otherwise, you can inspect elements and view the results in the dev tools panel.

🧢 Your Project:

@rspbot
Copy link

rspbot commented Jun 3, 2025

Build successful! 🎉

@snowystinger snowystinger marked this pull request as ready for review June 3, 2025 06:14
@rspbot
Copy link

rspbot commented Jun 3, 2025

Build successful! 🎉

@rspbot
Copy link

rspbot commented Jun 3, 2025

Build successful! 🎉

@rspbot
Copy link

rspbot commented Jun 4, 2025

Build successful! 🎉

@rspbot
Copy link

rspbot commented Jun 5, 2025

Build successful! 🎉

@snowystinger snowystinger changed the title [WIP] feat: Style macro devtool feat: Style macro devtool Jun 5, 2025
@rspbot
Copy link

rspbot commented Jun 5, 2025

Build successful! 🎉

@rspbot
Copy link

rspbot commented Jun 5, 2025

Build successful! 🎉

@rspbot
Copy link

rspbot commented Jun 5, 2025

Build successful! 🎉

@rspbot
Copy link

rspbot commented Jun 6, 2025

Build successful! 🎉

@rspbot
Copy link

rspbot commented Jun 6, 2025

Build successful! 🎉

@snowystinger snowystinger force-pushed the style-macro-devtool branch from 994911b to 2706cd1 Compare June 6, 2025 05:03
@rspbot
Copy link

rspbot commented Jun 6, 2025

Build successful! 🎉

# Conflicts:
#	package.json
#	packages/@react-spectrum/s2/style/__tests__/style-macro.test.js
#	packages/@react-spectrum/s2/style/style-macro.ts
#	packages/dev/parcel-config-storybook/package.json
#	packages/dev/s2-icon-builder/package.json
#	yarn.lock
@rspbot
Copy link

rspbot commented Dec 18, 2025

@rspbot
Copy link

rspbot commented Dec 18, 2025

differentiate between hash conflicts when same style is used in multiple files
LFDanLu
LFDanLu previously approved these changes Dec 18, 2025
@rspbot
Copy link

rspbot commented Jan 6, 2026

@rspbot
Copy link

rspbot commented Jan 6, 2026

@rspbot
Copy link

rspbot commented Jan 6, 2026

reidbarber
reidbarber previously approved these changes Jan 7, 2026
Copy link
Member

@reidbarber reidbarber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Tested in our storybook.

yihuiliao
yihuiliao previously approved these changes Jan 8, 2026
Copy link
Member

@yihuiliao yihuiliao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested on the s2 storybook, i like the logo haha

devongovett
devongovett previously approved these changes Jan 8, 2026
// the defaults from the style definition are omitted.
let allowedOverridesSet = new Set<string>();
let js = 'let rules = " ";\n';
let js = 'let rules = " ", currentRules = {};\n';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only needed in dev builds right?

Copy link
Member Author

@snowystinger snowystinger Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, i was struggling with how to do that, can try again monday

this.pseudos = '';
this.property = property;
this.value = value;
if (isCompilingDependencies !== null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remind me what this is for? Why is it only when compiling dependencies?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be perfectly honest, I have no idea, this was part of the code i copied over from your work

it seems to have something to do with self() references, but I don't follow the logic at line 285 where it progresses from a dependency name, to null, to false.

given that it has to do with self() though, i'm guessing this allows us to go past that as a value to display and go to the compiled value?

copy(): Rule
}

let conditionStack: string[] = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps at some point we can refactor this to not rely on global state

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂

@rspbot
Copy link

rspbot commented Jan 13, 2026

@rspbot
Copy link

rspbot commented Jan 13, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants